/**
 * ReportGear(2011)
 */
package com.reportgear.report.model.cell.style;

import java.util.ArrayList;
import java.util.List;

import com.reportgear.report.core.api.idname.DefaultIdName;
import com.reportgear.report.core.api.idname.IdName;

/**
 * 横向对齐方式
 * 
 * @version 1.0 2011-3-9
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public enum HorizentalAlignment {
	/**
	 * 靠左
	 */
	LEFT("L"),
	/**
	 * 居中
	 */
	CENTER("C"),
	/**
	 * 靠右
	 */
	RIGHT("R"),
	/**
	 * 分散对齐
	 */
	ALIGN("A");
	/**
	 * 获取单元格水平对齐样式列表
	 * 
	 * @return 水平样式列表
	 */
	public static List<IdName<HorizentalAlignment>> getIdNameList() {
		List<IdName<HorizentalAlignment>> ret = new ArrayList<IdName<HorizentalAlignment>>();

		ret.add(new DefaultIdName<HorizentalAlignment>(LEFT, "靠左"));
		ret.add(new DefaultIdName<HorizentalAlignment>(CENTER, "居中"));
		ret.add(new DefaultIdName<HorizentalAlignment>(RIGHT, "靠右"));
		ret.add(new DefaultIdName<HorizentalAlignment>(ALIGN, "分散对齐"));

		return ret;
	}

	// 简化代码
	private String code;

	HorizentalAlignment(String code) {
		this.code = code;
	}

	public String getCode() {
		return code;
	}

	public HorizentalAlignment getByCode(String code) {
		if ("L".equals(code)) {
			return LEFT;
		} else if ("C".equals(code)) {
			return CENTER;
		} else if ("R".equals(code)) {
			return RIGHT;
		}

		return ALIGN;
	}
}
